package com.whfc.iot.mach.processor;

import com.whfc.iot.mach.constant.MsgConst;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * @author: xugcheng
 * @version: 1.0
 * @date: 2019/8/29 15:13
 */
@Component
public class MachUpMsgProcessorFactory {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private MachUpMsgProcessor0x01 processor0x01;

    @Autowired
    private MachUpMsgProcessor0x02 processor0x02;

    @Autowired
    private MachUpMsgProcessor0x03 processor0x03;

    @Autowired
    private MachUpMsgProcessor0x04 processor0x04;

    @Autowired
    private MachUpMsgProcessor0x05 processor0x05;

    @Autowired
    private MachUpMsgProcessor0x06 processor0x06;

    @Autowired
    private MachUpMsgProcessor0x07 processor0x07;

    @Autowired
    private MachUpMsgProcessor0x08 processor0x08;

    @Autowired
    private MachUpMsgProcessor0x09 processor0x09;

    @Autowired
    private MachUpMsgProcessor0x0A processor0x0A;

    @Autowired
    private MachUpMsgProcessor0x0B processor0x0B;

    @Autowired
    private MachUpMsgProcessor0x0C processor0x0C;

    /**
     * 获取消息处理器
     *
     * @param cmd
     * @return
     */
    public MachUpMsgProcessor getMsgProcessor(int cmd) {
        MachUpMsgProcessor processor = null;
        switch (cmd) {
            case MsgConst.UPSTREAM_CMD_0x01:
                processor = processor0x01;
                break;
            case MsgConst.UPSTREAM_CMD_0x02:
                processor = processor0x02;
                break;
            case MsgConst.UPSTREAM_CMD_0x03:
                processor = processor0x03;
                break;
            case MsgConst.UPSTREAM_CMD_0x04:
                processor = processor0x04;
                break;
            case MsgConst.UPSTREAM_CMD_0x05:
                processor = processor0x05;
                break;
            case MsgConst.UPSTREAM_CMD_0x06:
                processor = processor0x06;
                break;
            case MsgConst.UPSTREAM_CMD_0x07:
                processor = processor0x07;
                break;
            case MsgConst.UPSTREAM_CMD_0x08:
                processor = processor0x08;
                break;
            case MsgConst.UPSTREAM_CMD_0x09:
                processor = processor0x09;
                break;
            case MsgConst.UPSTREAM_CMD_0x0A:
                processor = processor0x0A;
                break;
            case MsgConst.UPSTREAM_CMD_0x0B:
                processor = processor0x0B;
                break;
            case MsgConst.UPSTREAM_CMD_0x0C:
                processor = processor0x0C;
                break;
            default:
                logger.info("无法解析的指令,cmd:{}", cmd);
                break;
        }
        return processor;
    }
}
